import React, { FC, useState } from 'react';
import styles from './addTask.less';
import { Button, Form, Input } from 'antd';
import { SaveOutlined } from '@ant-design/icons';
import { IRouteComponentProps } from '@umijs/renderer-react';
import useStore from '@/context/useStore';
import { observer } from 'mobx-react-lite';
import { addTask } from '@/services'
import { Link } from 'umi';
const addTaskList: FC<IRouteComponentProps> = ({ location, history }) => {
    let { addIndustry } = useStore();
    //连接form
    const [form] = Form.useForm();
    const [taskName, settaskName] = useState('');
    const [assessmentStandard, setassessmentStandard] = useState('');
    const [subjectTime, setsubjectTime] = useState('');
    //保存
    const AddTask = () => {
        addTask({ ...addIndustry.addTaskItem, taskName, assessmentStandard, subjectTime, proVersionId:location.query.versionId ,proid:location.query.proId,steptCount:''}).then(res => {
        })
    }
    return <div className={styles.addTask}>
        <div className={styles.box}>
            <div className={styles.header}>
                <span>项目</span>
                <span>/</span>
                <span>添加任务</span>
            </div>
            <div className={styles.title}>
                <h3>添加项目</h3>
                <p><Link to={`/teachers/addProject?versionId=${location.query.versionId}&proId=${location.query.proId}&see=false`}><Button>返回</Button></Link></p>
            </div>
            <Form
                className={styles.Form}
                onFinish={AddTask}
                form={form}
                key={JSON.stringify(addIndustry.addTaskItem)}
                initialValues={{ ...addIndustry.addTaskItem, ...addIndustry.addTaskItem }}
            >
                <div className={styles.f1}>
                    <Button type="text" icon={<SaveOutlined />} htmlType="submit">保存</Button>
                </div>
                <div>
                    <Form.Item label="任务名称" name='taskName' rules={[{ required: true, message: "请输入任务名称" }]} >
                        <Input className={styles.n1} placeholder='请输入任务名称' onChange={e => settaskName(e.target.value)} />
                    </Form.Item>
                </div>
                <div>
                    <Form.Item label="考核标准" name='assessmentStandard' rules={[{ required: true, message: "请输入考核标准" }]} >
                        <Input className={styles.n1} placeholder='请输入考核标准' onChange={e => setassessmentStandard(e.target.value)} />
                    </Form.Item>
                </div>
                <div>
                    <Form.Item label="推荐工期" name='subjectTime' rules={[{ required: true, message: "请输入推荐工期" }]} >
                        <Input type='number' onChange={e => setsubjectTime(e.target.value)} />
                    </Form.Item>
                </div>
            </Form>
        </div>
    </div>
}
export default observer(addTaskList)